﻿using UnityEngine;
using System.Collections;

public class KillGameObjectScrips : MonoBehaviour
{

		// Use this for initialization
		void Start ()
		{
	
		}
	
		// Update is called once per frame
		void Update ()
		{
	
		}

		void OnCollisionEnter2D (Collision2D col)
		{
				Debug.Log ("---------------------trigger-------------");
				// If the player hits the trigger...
				if (col.gameObject.tag == "Player") {
						//ReloadGame ();
						Destroy (col.gameObject);
				}
				if (col.gameObject.tag == "enemy") {
						Destroy (col.gameObject);
				}
		}

		IEnumerator ReloadGame ()
		{			
				// ... pause briefly
				yield return new WaitForSeconds (2);
				// ... and then reload the level.
				Application.LoadLevel (Application.loadedLevel);
		}
}
